﻿/// Copyright © 2013 Microsoft Corporation. 
/// This project is released under the Microsoft Public License (MS-PL)
///
namespace Azure.Performance
{
    using System;
    using Microsoft.WindowsAzure.ServiceRuntime;

    public class BenchmarkHelper
    {
        //This method simply determines instance size based on memory
        public static string GetInstanceSize()
        {
            if (!RoleEnvironment.IsAvailable || RoleEnvironment.IsEmulated)
                return "non-azure";

            var ci = new Microsoft.VisualBasic.Devices.ComputerInfo();
            var memory = ci.TotalPhysicalMemory / 1024d / 1024d / 1024d;

            if (memory > 12) return "azure-extralarge";
            if (memory > 6) return "azure-large";
            if (memory > 3) return "azure-medium";
            if (memory > 1) return "azure-small";

            return "azure-extrasmall";
        }

        public static string GetAzureDataCenter()
        {
            //TODO: Change this to discover what data center we are deployed in
            return "US West";
        }

        private static string DisplaySize(long bytes)
        {
            if (bytes >= 1024 * 1024 * 1024) return (bytes / 1024 / 1024 / 1024) + "GB";
            if (bytes >= 1024 * 1024) return (bytes / 1024 / 1024) + "MB";
            if (bytes >= 1024) return (bytes / 1024) + "kb";
            return bytes + " bytes";
        }

        // Call a few operations to run a quick latency test on the target account
        public static int GetApproximateStorageLatency(string storageAccount)
        {
            //
            return 0;
        }
    }
}
